import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage>
    with SingleTickerProviderStateMixin {
  @override
  Widget build(BuildContext context) {
    //脚手架
    return Scaffold(
      appBar: AppBar(
        title: Text('列表'),
        backgroundColor: Colors.blue,
        foregroundColor: Colors.white,
      ),

      body: buildListView1(),
    );
  }

  //
  ListView buildListView1() {
    return ListView.builder(
      //数据数量
      itemCount: 100,
      //每个Item的样式
      itemBuilder: (BuildContext context, int index) {
        return ListTile(
          leading: Image.asset('asset/images/s01.png'),
          title: Text('早起的年轻人 $index'),
          subtitle: Text('今天 正在写代码中今天 正在写代码中今天 正在写代码中今天 正在写代码中。。。'),
          trailing: Icon(Icons.arrow_forward_ios_rounded),
          onTap: () {
            print('点击了');
          },
        );
      },
    );
  }
}
